package com.example.travel.fragment;

import android.os.Bundle;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import androidx.fragment.app.Fragment;


import com.example.travel.Interface.Implements.UserInterfaceImpl;
import com.example.travel.R;

import java.util.ArrayList;
import java.util.HashMap;


public class SearchContactListFragment extends Fragment {
    ListView lv;
    Button btBack;
    ArrayList<HashMap<String, Object>> userList=new ArrayList<HashMap<String, Object>>();
    SimpleAdapter sa;
    UserInterfaceImpl userInterface;
    int positoin;
    int user_id;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view=inflater.inflate(R.layout.search_contact_list, container, false);
        lv=(ListView)view.findViewById(R.id.lv_searchUserList);
        btBack=(Button)view.findViewById(R.id.bt_searchBack);
        String userName=getArguments().getString("searchName");
        userInterface=new UserInterfaceImpl(getContext());
        userList=userInterface.getAllUsersByName(userName);
        sa=new SimpleAdapter(getContext(),userList,R.layout.browselist,
                new String[]{"user_name","phone"},new int[]{R.id.tv_name,R.id.tv_phone});
        lv.setAdapter(sa);
        registerForContextMenu(lv);
        return view;
    }

}
